/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function lTrim(sString)//bo ky tu trang dau cau
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    return sString;
}

function rTrim(sString)
{
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function Trim(sString)
{
    if(sString==null){
        return '';
    }
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}
function IsPositiveNumber(sText)
{
    var t=Trim(sText);
    var ValidChars = "0123456789";
    var IsNumber=true;
    var Char;

    for (i = 0; i < t.length && IsNumber == true; i++)
    {
        Char = t.charAt(i);
        if (ValidChars.indexOf(Char) == -1)
        {
            IsNumber = false;
            return false;
        }
    }
    return true;
}

function $(id){
   if(document.getElementById(id)==null){
       return null;
   }
   else{
       return document.getElementById(id).value;
   }
}